RAIS  3.2
C:/Projekte/RAIS/common/UserAssignment.cs
Go to the documentation of this file.
00001 
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031 using System.Data;
00032 
00033 namespace RAIS.Common.UserManagement
00034 {
00038     public class UserAssignment : DBObject
00039     {
00040         #region Fields
00041         UserData takenOverUser;
00042         DateTime validFrom;
00043         DateTime validUntil;
00044         bool isDeleted;
00045         string logOperation;
00046         DateTime logOperationDate;
00047         #endregion
00048         #region Properties
00049 
00052         public string LogOperation
00053         {
00054             get
00055             {
00056                 return this.logOperation;
00057             }
00058         }
00059 
00063         public DateTime LogOperationDate
00064         {
00065             get { return this.logOperationDate; }
00066         }
00067 
00071         public bool IsDeleted 
00072         {
00073             get 
00074             {
00075                 if (this.isDeleted != null)
00076                     return this.isDeleted;
00077                 return false;
00078             }
00079         }
00083         public string Deleted
00084         {
00085             get
00086             {
00087                 if (this.isDeleted)
00088                     return "Yes";
00089                 return "No";
00090             }
00091         }
00092 
00096         public DateTime ValidFrom
00097         {
00098             get { return this.validFrom; }
00099             set { this.validFrom = value; }
00100         }
00104         public DateTime ValidUntil
00105         {
00106             get { return this.validUntil; }
00107             set { this.validUntil = value; }
00108         }
00109 
00110         public string ValidFromFormatted
00111         {
00112             get
00113             {
00114                 return this.validFrom.ToString(string.Format("{0} HH:mm"
00115                   , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
00116             }
00117         }
00118 
00119         public string ValidUntilFormatted
00120         {
00121             get
00122             {
00123                 return this.validUntil.ToString(string.Format("{0} HH:mm"
00124                   , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
00125             }
00126         }
00127         public string LogOperationDateFormatted
00128         {
00129             get
00130             {
00131                 return this.logOperationDate.ToString(string.Format("{0} HH:mm"
00132                   , System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern));
00133             }
00134         }
00135 
00139         public UserData TakenOverUser
00140         {
00141             get { return this.takenOverUser; }
00142             set { this.takenOverUser = value; }
00143         }
00147         public string TakenOverName
00148         {
00149             get 
00150             {
00151                 if (this.takenOverUser != null)
00152                     return this.takenOverUser.Login;
00153                 return string.Empty;
00154             }
00155         }
00156         
00157                 #endregion
00158         #region Constructors
00159         public UserAssignment()
00160         {}
00161         public UserAssignment(IDataRecord record)
00162         {
00163             this.ID = (int)record["PK Message Box Restriction Take Over ID"];
00164             this.takenOverUser = new UserData();
00165             if (!(record["PK User ID"] is DBNull))
00166                 this.takenOverUser.ID = (int)record["PK User ID"];
00167             if(!(record["User Name"] is DBNull))
00168                 this.takenOverUser.Login = record["User Name"].ToString();
00169             if (!(record["Valid From"] is DBNull))
00170             {
00171                 this.validFrom = (DateTime)record["Valid From"];
00172             }
00173             if (!(record["Valid Until"] is DBNull))
00174             {
00175                 this.validUntil = (DateTime)record["Valid Until"];
00176             }
00177             try
00178             {
00179                 if (record["Is Deleted"] != null && !(record["Is Deleted"] is DBNull))
00180                     this.isDeleted = (bool)record["Is Deleted"];
00181             }
00182             catch (Exception)
00183             {
00184                 this.isDeleted = false;
00185             }
00186 
00187             try
00188             {
00189                 if (record["Operation"] != null && !(record["Operation"] is DBNull))
00190                     this.logOperation = (string)record["Operation"];
00191                 else
00192                     this.logOperation = null;
00193             }
00194             catch (Exception)
00195             {
00196                 this.logOperation = null;
00197             }
00198 
00199             try
00200             {
00201                 if (record["Operation Date"] != null && !(record["Operation Date"] is DBNull))
00202                     this.logOperationDate = (DateTime)record["Operation Date"];
00203             }
00204             catch (Exception)
00205             {
00206 
00207             }
00208 
00209 
00210         }
00211                 #endregion
00212         
00213     }
00214 }